package com.andox.fn.inf.rpc.rest.config;

import java.io.Serializable;

import com.google.common.base.Preconditions;

/**   
 * @ClassName:   ReferenceConfig   
 * @author:      Andox
 * @date:        2019年7月31日 下午5:56:54   
 *     
 */
public class ReferenceConfig extends InterfaceConfig implements Serializable{
	private static final long serialVersionUID = 1974635267394941868L;

	private String baseUrl;
	
	private boolean async;
	private boolean oneway;
	
	private String loadbalance = "robin";
	
	@Override
	public void checkSelf() {
		super.checkSelf();
		
		Preconditions.checkArgument((this.getBaseUrl() != null && this.getBaseUrl().startsWith("http://") 
				|| (this.getRegistry() != null)), "baseUrl must start with http://(direct mode) or registry(normal mode) must be setted");
		Preconditions.checkArgument(this.getTimeout() > 0, "timeout must positive integer or default value(3000 ms)");
	}
	
	public String getBaseUrl() {
		return baseUrl;
	}
	public void setBaseUrl(String baseUrl) {
		this.baseUrl = baseUrl;
	}
	public boolean isAsync() {
		return async;
	}
	public void setAsync(boolean async) {
		this.async = async;
	}
	public boolean isOneway() {
		return oneway;
	}
	public void setOneway(boolean oneway) {
		this.oneway = oneway;
	}

	public String getLoadbalance() {
		return loadbalance;
	}

	public void setLoadbalance(String loadbalance) {
		this.loadbalance = loadbalance;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}	
}
